import * as VueRouter from "vue-router";

const routes = [
  {
    path: "/dashboard",
    name: "Dashboard",
    component: () => import("@/views/dashboard/Dashboard.vue"),
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/Login.vue"),
  },
  {
    path: "",
    redirect: "/login",
  },
  {
    path: "/:pathMatch(.*)*",
    redirect: "/login",
  },
];

export const router = VueRouter.createRouter({
  history: VueRouter.createWebHistory(),
  routes,
  scrollBehavior: () => ({ left: 0, top: 0 }), // 刷新时，滚动条位置还原
});

/**
 * 注册路由
 * @param {Vue} app - Vue实例
 */
export function RegisterRouter(app) {
  app.use(router);
}
